package com.ibm.workplace.wcm.cqplugin.ui.preference;

import org.eclipse.jface.preference.*;
import org.eclipse.jface.resource.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.*;

import com.ibm.workplace.wcm.cqplugin.*;
import com.ibm.workplace.wcm.cqplugin.preference.*;

public class CqPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {

    private ConfigureCqConnectionProfilesComposite profilesComposite;

    public CqPreferencePage() {
        super();
    }

    public CqPreferencePage(String arg0, ImageDescriptor arg1) {
        super(arg0, arg1);
    }

    public CqPreferencePage(String arg0) {
        super(arg0);
    }

    public void init(IWorkbench arg0) {

    }

    protected Control createContents(Composite arg0) {
        profilesComposite = new ConfigureCqConnectionProfilesComposite(arg0, 0);
        profilesComposite.init(getPreferenceStore());

        return profilesComposite;
    }

    protected void performApply() {
        profilesComposite.store(getPreferenceStore());

        getPreferenceStore().setValue(BugInfoPreferenceConstants.PREF_SETTINGS_CONFIGURED, true);

        super.performApply();
    }

    public boolean performOk() {
        profilesComposite.store(getPreferenceStore());

        getPreferenceStore().setValue(BugInfoPreferenceConstants.PREF_SETTINGS_CONFIGURED, true);

        return super.performOk();
    }

    protected IPreferenceStore doGetPreferenceStore() {
        return Activator.getDefault().getPreferenceStore();
    }

    protected void performDefaults() {
        profilesComposite.init(getPreferenceStore());        
    }
}
